﻿
namespace OpenPms.Data;
[EntityTypeConfiguration(typeof(TOrderQuantityConfig))]
public class TQuantity
{
    public Guid RoomTypeId { get; set; }
    public DateOnly Date { get; set; }
    /// <summary>
    /// 预订数量
    /// </summary>
    public int Ordered { get; set; }

    /// <summary>
    /// 不能预订的数量，比如维修房
    /// </summary>
    public int OutOfOrder { get; set; }
    /// <summary>
    /// 不可预订量
    /// </summary>
    public int Quantity { get; set; }
    public int HotelId { get; set; }
}

public class TOrderQuantityConfig : IEntityTypeConfiguration<TQuantity>
{
    public void Configure(EntityTypeBuilder<TQuantity> builder)
    {
        builder.HasKey(ii => new { ii.RoomTypeId, ii.Date });
        builder.Property(ii => ii.Quantity).HasComputedColumnSql("Ordered+OutOfOrder");
        builder.HasIndex(ii => new {ii.HotelId, ii.Date});
    }
}

